
//defination Triangle class



#include "Triangle.h"

Triangle::Triangle(){


   x1=x2=100;
   y1=y2=-100;
   x3=y3=0;
   
}


Triangle::Triangle(const MyDisplay &another):Line(another){

//   Triangle();   


   x1=x2=100;
   y1=y2=-100;
   x3=y3=0;


}

Triangle::Triangle(const Matrix &R){


   x1 =(int) R[0][0];
   y1 =(int) R[0][1];
   
   x2 =(int) R[1][0];
   y2 =(int) R[1][1];
   
   x3 =(int) R[2][0];
   y3 =(int) R[2][1];

     
}


Triangle::Triangle(const char *fileName,const MyDisplay &another):Line(another){

  
      ifstream in(fileName);

      	int tempx1,tempy1,d;
	if(!in)
	{
	    cout <<"\n unable to open file : " <<fileName;
	     return;	
	}
	
	//out <<numRows() <<"   "  <<numCols() <<"\n\n";
	
	    in >>tempx1>>tempy1;
	       if(tempx1 != 3 && tempy1!= 2){
	       
	          cout <<fileName<<" Doesnot have rectangle"<<endl;
		  return;
	       }
	    
	    in >>tempx1>>tempy1>>d;
	    
	    x1 = abs(tempx1);
	    y1 = abs(tempy1);
	    
	    in >>tempx1>>tempy1>>d;
	    
	    x2 = abs(tempx1);
	    y2 = abs(tempy1);
	    
   	    in >>tempx1>>tempy1>>d;
	    
	    x3 = abs(tempx1);
	    y3 = abs(tempy1);
	    
            in.close();

}


Triangle::~Triangle(){

}


bool Triangle::draw(){

  drawLine(x1,y1,x2,y2);
  drawLine(x1,y1,x3,y3);
  drawLine(x2,y2,x3,y3);
  
  
  
return true;
}




bool Triangle::draw(const Matrix &T){


   x1 =(int) T[0][0];
   y1 =(int) T[0][1];
   
   x2 =(int) T[1][0];
   y2 =(int) T[1][1];
   
   x3 =(int) T[2][0];
   y3 =(int) T[2][1];

   
   
   draw();

}

bool Triangle::draw(const int x1,const int y1,const int x2,const int y2,const int x3,const int y3){


     this->x1 = x1;
     this->y1 = y1;
     
     this->x2 = x2;
     this->y2 = y2;
     
     this->x3 = x3;
     this->y3 = y3;

     draw();
}
